package com.qf.controller;

import com.qf.feign.CustomerFeign;
import com.qf.pojo.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 千锋健哥
 */
@RestController
@RequestMapping("/test2")
public class Test2Controller {

    @Autowired
    private CustomerFeign feign;


    /**
     * 查询一个
     * @param id
     * @return
     */
    @GetMapping("/one/{id}")
    public Customer findOne(@PathVariable(value = "id") Integer id) {
        Customer one = feign.findOne(id);
        return one;
    }

    @GetMapping("/all")
    public List<Customer> findAll() {
        List<Customer> list = feign.findAll();
        return list;
    }

    @PostMapping("/add")
    public String add(@RequestBody Customer customer) {
        String str = feign.add(customer);
        return str;
    }

    @PutMapping("/update")
    public String update(@RequestBody Customer customer) {
        String str = feign.update(customer);
        return str;
    }

    @DeleteMapping("/delete/{id}")
    public String delete(@PathVariable(value = "id") Integer id) {
        String str = feign.delete(id);
        return str;
    }
}
